<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>springboot-oss-文件上传测试</title>
  <!-- import vue.js -->
  <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
  <!-- 引入 element 样式 -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <!-- 引入 element 组件库 -->
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
  <h1 v-text="message"></h1>

  <el-upload
      class="upload-demo"
      action="http://localhost:8080/upload"
      name="file"
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :file-list="fileList"
      list-type="picture">
    <el-button size="small" type="primary">点击上传</el-button>
    <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
  </el-upload>
</div>

<script>
  new Vue({
    el: '#app',
    data() {
      return {
        message: 'Hello Vue!',
        fileList: []
      }
    },
    methods: {
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      }
    }
  })
</script>
</body>
</html>
